package com.yw.controller;

import com.yw.result.R;
import com.yw.service.NodeService;
import com.yw.task.domain.Node;
import com.yw.task.dto.AddNodeDTO;
import com.yw.task.dto.ArrowDTO;
import com.yw.task.dto.AutomaticDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@CrossOrigin(origins = "*")  //解决跨域
@Tag(name = "脚本节点管理",description = "脚本节点管理")
@RequestMapping("/node")
public class NodeController {

    @Resource
    private NodeService nodeService;

    @Operation(summary = "添加节点")
    @PostMapping("/addNode")
    public R addNode(@RequestBody AddNodeDTO addNodeDTO){
        return R.OK(nodeService.addNode(addNodeDTO));
    }

    @Operation(summary = "自动解析")
    @PostMapping("/automatic")
    public R automatic(@RequestBody AutomaticDTO automaticDTO){
        return R.OK(nodeService.automatic(automaticDTO));
    }

    @Operation(summary = "箭头接口")
    @PostMapping("/UpAndDownIdAssignment")
    public R UpAndDownIdAssignment(@RequestBody ArrowDTO arrowDTO){
        return R.OK(nodeService.UpAndDownIdAssignment(arrowDTO));
    }
}
